package cn.imvc.app.controllers.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import cn.imvc.app.entities.RefRelation;
import cn.imvc.app.entities.Resource;
import cn.imvc.app.models.RefRelationModel;
import cn.imvc.core.DialogBean;
import cn.imvc.core.Render;
import cn.imvc.data.domain.ViewRequest;

public class RefRelationControllerImpl implements RefRelationController {
	public Page<RefRelation> page;
	public RefRelation refRelation;
	public ViewRequest viewRequest;
	public int id;
	private int[] ids;
	@Autowired
	private RefRelationModel refRelationModel;
	
	public String search() {
		// TODO Auto-generated method stub
		return null;
	}

	public String index() {
		page = refRelationModel.findAll(viewRequest);
		return "ref-relation/index";
	}

	public String show() {
		refRelation = refRelationModel.getOne(id);
		return "ref-relation/show";
	}

	public String editNew() {
		return "ref-relation/edit";
	}

	public String create() {
		refRelationModel.save(refRelation);
		return Render.json(new DialogBean("200", "保存成功","","closeCurrent"));
	}

	public String edit() {
		refRelation = refRelationModel.getOne(id);
		return "ref-relation/edit";
	}

	public String update() {
		refRelationModel.update(id,refRelation);
		return Render.json(new DialogBean("200", "更新成功","","closeCurrent"));
	}

	public String destroy() {
		refRelationModel.delete(id);
		return Render.json(new DialogBean("200", "删除成功",""));
	}

	public String destroyBatch() {
		refRelationModel.deleteBatch(ids);
		return Render.json(new DialogBean("200", "批量删除删除成功",""));
	}

	public Page<RefRelation> getPage() {
		return page;
	}

	public void setPage(Page<RefRelation> page) {
		this.page = page;
	}

	public RefRelation getRefRelation() {
		return refRelation;
	}

	public void setRefRelation(RefRelation refRelation) {
		this.refRelation = refRelation;
	}

	public ViewRequest getViewRequest() {
		return viewRequest;
	}

	public void setViewRequest(ViewRequest viewRequest) {
		this.viewRequest = viewRequest;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int[] getIds() {
		return ids;
	}

	public void setIds(int[] ids) {
		this.ids = ids;
	}
}
